Skip to content

REGR: concat materializing index even if sort is not necessary #47508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 30, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Jun 25, 2022

@phofl phofl added Regression Functionality that used to work in a prior pandas version Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Jun 25, 2022
@phofl phofl added this to the 1.4.4 milestone Jun 25, 2022
@@ -157,7 +157,7 @@ def _get_combined_index(
index = union_indexes(indexes, sort=False)
index = ensure_index(index)

if sort:
if sort and not index.is_monotonic_increasing:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe better to just have safe_sort check this internally? (we do this in sort_values for example)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index.is_monotonic_decreasing as well?

Also I think a separate PR will need to be made against 1.4.x. safe_sort_index below is available on main and not 1.4.x

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sorry, should have mentioned this. I’ll clean this up after this is backported

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So to confirm, once this is merged into main and backported, you'll modify the backport branch to be compatable with the 1.4.x branch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this should be compatible with 1.4.x if I am not missing anything.

I will create a new pr after this is merged and will move the no op check to safe_sort_index

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay gotcha. So does is_monotonic_decreasing also need to be added too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think so, if you want to sort and it is decreasing, you would have to turn the Range index around basically. We could add some logic for this, but not for 1.4.x I think

@jreback
Copy link
Contributor

jreback commented Jun 26, 2022

this version prob ok for 1.4

can do enhanced for 1.5

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jreback if any additional comments

@mroeschke mroeschke merged commit 6fd3376 into pandas-dev:main Jun 30, 2022
@mroeschke
Copy link
Member

Thanks @phofl

@lumberbot-app

This comment was marked as resolved.

@mroeschke
Copy link
Member

Could you manual backport when you get the chance @phofl?

@phofl
Copy link
Member Author

phofl commented Jun 30, 2022

Yep, will do tomorrow

phofl added a commit to phofl/pandas that referenced this pull request Jul 1, 2022
…s-dev#47508)

* REGR: concat materializing index even if sort is not necessary

* Add check for index

* Add exact
@phofl phofl deleted the 47501 branch July 1, 2022 07:22
@phofl
Copy link
Member Author

phofl commented Jul 1, 2022

#47565

The conflict was caused by tests :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression Functionality that used to work in a prior pandas version Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PERF: concat along axis 1 unnecessarily materializes RangeIndex->Int64Index
3 participants